﻿#pragma once
#include "Matrix.h"
#include "CoordSys.h"
#include "GNSSSatPos.h"
#include "IonoCorr.h"
#include "TropCorr.h"
#include "ReadO.h"
#include "ReadN.h"
#include "TimeSys.h"

//单点定位解算器

class SPPSolver {
public:
    // 系统常量
    static constexpr double SPEED_OF_LIGHT = 299792458.0; // 光速(m/s)
    static constexpr int MAX_ITERATIONS = 10;             // 最大迭代次数
    static constexpr double CONVERGENCE_THRESHOLD = 0.05; // 收敛阈值(m)

    // 构造函数
    SPPSolver(
        CoordSys* coordSys,
        GNSSSatPos* satPosCalculator,
        IonoCorr* ionoCorrector,
        TropCorr* tropCorrector,
        ReadO* obsReader,
        ReadN* navReader,
        TimeSys* timeSys
    );

    //处理单个历元的定位解算
    bool solve_epoch(int epochIndex, XYZ& receiverPos, double& clockBias);

private:
    CoordSys* mCoordSys;          // 坐标系统
    GNSSSatPos* mSatPosCalculator; // 卫星位置计算
    IonoCorr* mIonoCorrector;     // 电离层改正
    TropCorr* mTropCorrector;     // 对流层改正
    ReadO* mObsReader;            // 观测文件读取
    ReadN* mNavReader;            // 星历文件读取
    TimeSys* mTimeSys;            // 时间系统
};